'''
Created on 2009-9-4

@author: LiPengYu
'''

import cherrypy
import environment
from abio.util import session

def role(rolename):
    def decorator(handler):
        def function(self, *para):
            if rolename == session.role():
                return handler(self, *para)
            else:
                raise cherrypy.HTTPRedirect(environment.server['url']+'/sys/account')
                return None
        return function
    return decorator
